<style>
  .layui-form-label.required:before {
    /* 这种写法也可以*/
    content: " *";
    color: red;
  }
  .open-form .layui-form-label {
    width: 110px;
  }
  .open-form .layui-input-block {
    margin-left: 140px;
  }
</style>

<script type="text/html" id="viewAttachmentHtml">
  <div id="example1" style="height: 100%;"></div>
</script>
<script type="text/javascript" src="../../../admin/assets/js/pdfobject.min.js"></script>
<!-- 表单弹窗 -->
<form lay-filter="productAuditReviewForm" class="layui-form open-form">
  <input name="id" type="hidden" />
  <div class="open-model">
    <div class="open-auto">
      <fieldset class="layui-elem-field layui-field-title">
        <legend>客户信息产品信息</legend>
      </fieldset>

      <div class="layui-form-item layui-row">
        <div class="layui-col-md3">
          <label class="layui-form-label">客户名称：</label>
          <div class="layui-input-block">
            <input name="customerName" disabled type="text" class="layui-input" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">客户产品类别：</label>
          <div class="layui-input-block">
            <input name="cusProductCategory" disabled type="text" class="layui-input" required autocomplete="off" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">客户SKU料号：</label>
          <div class="layui-input-block">
            <input name="cusSkuCode" type="text" disabled class="layui-input" required autocomplete="off" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">客户产品名称：</label>
          <div class="layui-input-block">
            <input name="cusProductName" disabled type="text" class="layui-input" required autocomplete="off" />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md3">
          <label class="layui-form-label">客户规格码：</label>
          <div class="layui-input-block">
            <input name="cusProductSpec" disabled type="text" class="layui-input" required autocomplete="off" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">附件信息：</label>
          <div class="layui-input-block" style="display: flex; align-items: center">
            <div id="addHeaderPdf" class="companyFormPhotos"></div>
            <input name="attachmentPdf" id="attachmentPdf" type="hidden" class="layui-input" />
            <label id="fileName" style="margin-left: 34px"></label>
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">需求数量：</label>
          <div class="layui-input-block">
            <input name="cusProductCount" disabled type="text" class="layui-input" required autocomplete="off" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">评审截止时间：</label>
          <div class="layui-input-block">
            <input name="reviewEndTime" disabled type="text" class="layui-input" />
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md3">
          <label class="layui-form-label required">计划交货时间：</label>
          <div class="layui-input-block">
            <input type="text" id="planGivenTime" disabled name="planGivenTime" class="layui-input" placeholder="请选择计划交货时间" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">包装说明：</label>
          <div class="layui-input-block">
            <input name="remark" disabled type="text" class="layui-input" />
          </div>
        </div>
      </div>

      <fieldset class="layui-elem-field layui-field-title">
        <legend>关联内部产品信息</legend>
      </fieldset>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md3">
          <label class="layui-form-label required">是否关联新料号：</label>
          <div class="layui-input-block">
            <select id="isUseOrAdd" name="isUseOrAdd" lay-filter="isUseOrAdd" class="common-select-search">
              <option value="">请选择</option>
              <option value="1">创建新产品</option>
              <option value="2">关联已有产品</option>
            </select>
          </div>
        </div>

        <div class="layui-col-md3">
          <label class="layui-form-label required">内部SKU号：</label>
          <div class="layui-input-block" id="SkuInfo">
            <div id="d1">
              <input type="text" id="inSkuCode" name="inSkuCode" class="layui-input" placeholder="请输入SKU号" />
              <input  id="inSkuCodeHave" name="inSkuCodeHave" style="display: none" />
            </div>
            <!-- <div id="d2" style="display: none;">
                            <select id="inSkuCodeHave" lay-search="" name="inSkuCodeHave" lay-filter="inSkuCodeHave"
                                    class="common-select-search">
                            </select>
                        </div> -->
          </div>
        </div>

        <div class="layui-col-md3">
          <label class="layui-form-label required">产品类别：</label>
          <div class="layui-input-block">
            <div id="productTypeName" lay-filter="productTypeName"></div>
            <input type="text" class="layui-input" id="productTypeId" name="productTypeId" style="display: none" />
            <input type="text" class="layui-input" id="productTypeId2" name="productTypeId2" style="display: none" />
          </div>
        </div>

        <div class="layui-col-md3">
          <label class="layui-form-label required">产品性质：</label>
          <div class="layui-input-block">
            <select id="productNature" name="productNature" lay-filter="productNature" class="common-select-search"></select>
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md3">
          <label class="layui-form-label required">内部SKU名称：</label>
          <div class="layui-input-block">
            <input type="text" id="inSkuName" name="inSkuName" class="layui-input" placeholder="请输入名称" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">内部规格码：</label>
          <div class="layui-input-block">
            <input type="text" id="inSkuSpec" name="inSkuSpec" class="layui-input" placeholder="请输入名称" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label required">基础单位：</label>
          <div class="layui-input-block">
            <input type="text" disabled id="inUnit" name="inUnit" class="layui-input" />
            <input type="hidden" id="inUnitId" name="inUnitId" class="layui-input" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label required">计量方式(主)：</label>
          <div class="layui-input-block">
            <select id="mainCalWay" name="mainCalWay" lay-filter="mainCalWay" class="layui-input borderNone"></select>
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md3">
          <label class="layui-form-label required">包装单位(主)：</label>
          <div class="layui-input-block">
            <select id="mainUnitId" name="mainUnitId" lay-filter="mainUnitId" class="layui-input borderNone"></select>
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label required">换算率(主)：</label>
          <div class="layui-input-block">
            <input type="text" id="mainUnitRate" name="mainUnitRate" class="layui-input" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">计量方式(辅)：</label>
          <div class="layui-input-block">
            <select id="subCalWay" name="subCalWay" lay-filter="subCalWay" class="layui-input borderNone"></select>
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">计量单位(辅)：</label>
          <div class="layui-input-block">
            <select id="subUnitId" name="subUnitId" lay-filter="mainUnitId" class="layui-input borderNone"></select>
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md3">
          <label class="layui-form-label">换算率(辅)：</label>
          <div class="layui-input-block">
            <input type="text" id="subUnitRate" name="subUnitRate" class="layui-input" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">成本核算类型：</label>
          <div class="layui-input-block">
            <select id="costCheckType" name="costCheckType" lay-filter="costCheckType" class="layui-input borderNone"></select>
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">是否质检：</label>
          <div class="layui-input-block">
            <select id="checkStatus" name="checkStatus" lay-filter="checkStatus" class="layui-input borderNone"></select>
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">是否料箱管理：</label>
          <div class="layui-input-block">
            <select id="boxStatus" name="boxStatus" lay-filter="boxStatus" class="layui-input borderNone"></select>
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-row">
        <div class="layui-col-md3">
          <label class="layui-form-label">建议最低价：</label>
          <div class="layui-input-block">
            <input name="suggestionMinPrice" id="suggestionMinPrice" type="text" class="layui-input" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">最低价：</label>
          <div class="layui-input-block">
            <input name="minPrice" id="minPrice" type="text" class="layui-input" />
          </div>
        </div>
        <div class="layui-col-md3">
          <label class="layui-form-label">说明：</label>
          <div class="layui-input-block">
            <input type="text" id="inRemark" name="inRemark" class="layui-input" />
          </div>
        </div>
      </div>
      <!--            <div class="layui-form-item layui-row">-->
      <!--                <div class="layui-col-md6">-->
      <!--                    <fieldset class="layui-elem-field layui-field-title">-->
      <!--                        <legend>图纸预览图</legend>-->
      <!--                    </fieldset>-->
      <!--                    <div id="TuZhiPdf" style="height: 100%;margin-left:10px">-->

      <!--                    </div>-->
      <!--                </div>-->
      <!--                <div class="layui-col-md6">-->
      <!--                    <fieldset class="layui-elem-field layui-field-title">-->
      <!--                        <legend>评审审核意见</legend>-->
      <!--                    </fieldset>-->
      <!--                    <div class="layui-col-md6">-->
      <!--                        <label class="layui-form-label">评估结果：</label>-->
      <!--                        <div class="layui-input-block">-->
      <!--                            <select id="result-sh" name="result" lay-filter="result"-->
      <!--                                    class="common-select-search">-->
      <!--                                <option value="">请选择</option>-->
      <!--                                <option value="0">审核不通过</option>-->
      <!--                                <option value="1">审核通过</option>-->
      <!--                            </select>-->
      <!--                        </div>-->
      <!--                    </div>-->
      <!--                    <div class="layui-col-md6">-->
      <!--                        <label class="layui-form-label">评估备注：</label>-->
      <!--                        <div class="layui-input-block">-->
      <!--                            <input type="text" id="reviewDesc" name="reviewDesc" class="layui-input">-->
      <!--                        </div>-->
      <!--                    </div>-->
      <!--                </div>-->
      <!--            </div>-->
    </div>
    <div class="layui-form-item text-right">
      <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">关闭</button>
      <button class="layui-btn" lay-filter="productAuditFormSubmit" lay-submit>保存</button>
    </div>
  </div>
</form>

<!-- js部分 -->
<script>
  layui.use(["layer", "form", "table", "laydate", "admin", "laytpl", "upload", "config"], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var admin = layui.admin;
    var table = layui.table;
    var form = layui.form;

    let oldSkuInfo = new Map();

    let data = admin.getTempData("reviewDataAudit");

    let productUnitList = [];

    let imagUrl = "";
    //页面加载时 拿到id

    let params = {};
    params.id = data.id;

    admin.getDictList("mainCalWay", "product_unit_cal_way", null, "辅助计量方式");
    admin.getDictList("subCalWay", "product_unit_cal_way", null, "主计量方式");

    admin.getDictList("costCheckType", "product_detail_cost_check_type", null, "成本核算");
    admin.getDictList("checkStatus", "sys_yes_no", null, "是否质检");
    admin.getDictList("boxStatus", "sys_yes_no", null, "是否料箱管理");

    form.on("select(isUseOrAdd)", function (data) {
      let val = data.value;
      $("#inSkuCode").val("");
      if (val == 1) {
        $("#inSkuCode").attr("placeholder", "请输入SKU");
        // document.getElementById("d2").style.display = "none";//隐藏
        // document.getElementById("d1").style.display = "";//显示
        setNoEdit("0");
      } else {
        $("#inSkuCode").attr("placeholder", "点击选择SKU");
        $("#inSkuCode").click(function () {
          admin.formOpen({
            area: "90%",
            offset: "50px",
            title: "配置物料清单",
            // path: "components/purchase/skuTableForm.html",
            path: "components/res/benchmarkBook/bookSkuTable.html",
            success: function () {
            },
            end: function () {
                if (childData.skuObj) {
                let skuInfo =  childData.skuObj;
                
                $("#inSkuCode").val(skuInfo.skuCode);
                $("#inSkuCodeHave").val(skuInfo.id);
                //回显
                //sku名称
                $("#inSkuName").val(skuInfo.skuName);
                //规格
                $("#inSkuSpec").val(skuInfo.skuSpec);
                // //计量单位
                // $('#inSkuUnit').val(skuInfo.unitId);

                $("#productTypeId2").val(skuInfo.productTypeId);

                // //基础单位数量
                // $('#inUnitCount').val(skuInfo.baseUnitCount);

                //产品性质
                $("#productNature").val(skuInfo.assemblyNature);

                admin.reqSync(
                  "enterprise/product/admin/productUnit/getIsBaseUnitProductUnitByType",
                  {
                    type: 0,
                    productTypeId: skuInfo.productTypeId
                  },
                  (res) => {
                    if (res.code === 200) {
                      if (res.data != null) {
                        let infoName = res.data.name || "";
                        let infoId = res.data.id || "";
                        $("#inUnit").val(infoName);
                        $("#inUnitId").val(infoId);
                      } else {
                        $("#inUnit").val("");
                        $("#inUnitId").val("");
                      }
                    }
                  },
                  "get"
                );
                //说明
                $("#inRemark").val(skuInfo.remark);

                $("#mainCalWay").val(skuInfo.mainCalWay);

                $("#mainUnitRate").val(skuInfo.mainUnitRate);
                $("#subCalWay").val(skuInfo.subCalWay);

                $("#subUnitRate").val(skuInfo.subUnitRate);
                $("#costCheckType").val(skuInfo.costCheckType);
                $("#checkStatus").val(skuInfo.checkStatus);
                $("#boxStatus").val(skuInfo.boxStatus);
                $("#minPrice").val(skuInfo.minPrice);
                $("#suggestionMinPrice").val(skuInfo.suggestionMinPrice);

                //主计量方式的改变事件
                admin.req("enterprise/product/admin/productType/getProductTypeVoById", { productTypeId: skuInfo.productTypeId }, (res) => {
                  if (res.code === 200) {
                    //包装单位集合
                    productUnitList = res.data.productUnitList;
                    productUnitList.forEach((v) => {
                      if (v.calWay == skuInfo.subCalWay) {
                        $("#subUnitId").append(new Option(v.name, v.id)); // 下拉菜单里添加元素
                      }
                    });

                    productUnitList.forEach((v) => {
                      if (v.calWay == skuInfo.mainCalWay) {
                        $("#mainUnitId").append(new Option(v.name, v.id)); // 下拉菜单里添加元素
                      }
                    });
                    form.render("select");
                    $("#mainUnitId").val(skuInfo.mainUnitId);
                    $("#subUnitId").val(skuInfo.subUnitId);
                  }
                });

                xmSelect.get("#productTypeName")[0].update({ disabled: true });
                form.render("select");
              }
            }
          });
        });
        // document.getElementById("d2").style.display = "";//隐藏
        // document.getElementById("d1").style.display = "none";//显示
        setNoEdit("1");
      }
      clearInfo();
    });

    function clearInfo() {
      $("#inSkuSpec").val("");
      $("#inSkuCodeHave").val("");
      $("#productNature").val("");
      xmSelect.get("#productTypeName")[0].setValue([]);
      $("#inSkuName").val("");
      $("#mainUnitRate").val("");
      $("#subCalWay").val("");
      $("#mainCalWay").val("");
      $("#subUnitRate").val("");
      $("#costCheckType").val("");
      $("#boxStatus").val("");
      $("#checkStatus").val("");
      $("#mainUnitId").val("");
      $("#subUnitId").val("");
      $("#inRemark").val("");
      $("#inUnit").val("");
      $("#minPrice").val("");
      $("#suggestionMinPrice").val("");
      $("#inUnitId").val("");
      form.render("select");
    }

    function setNoEdit(s) {
      let isCan = false;
      //设置为可选
      if (s === "1") {
        isCan = true;
      }
      xmSelect.get("#productTypeName")[0].update({ disabled: isCan });
      document.getElementById("inSkuName").disabled = isCan;
      document.getElementById("inSkuSpec").disabled = isCan;
      document.getElementById("productNature").disabled = isCan;
      document.getElementById("mainUnitRate").disabled = isCan;
      document.getElementById("subCalWay").disabled = isCan;
      document.getElementById("mainCalWay").disabled = isCan;
      document.getElementById("subUnitRate").disabled = isCan;
      document.getElementById("costCheckType").disabled = isCan;
      document.getElementById("boxStatus").disabled = isCan;
      document.getElementById("checkStatus").disabled = isCan;
      document.getElementById("mainUnitId").disabled = isCan;
      document.getElementById("subUnitId").disabled = isCan;
      document.getElementById("inRemark").disabled = isCan;
      form.render("select");
    }

    // 已有物料的选择事件
    form.on("select(inSkuCodeHave)", function (data) {
      let val = data.value;
      let skuInfo = {};
      if (oldSkuInfo.get(val)) {
        skuInfo = oldSkuInfo.get(val);
        console.log("skuInfo", skuInfo);
        //回显
        //sku名称
        $("#inSkuName").val(skuInfo.skuName);
        //规格
        $("#inSkuSpec").val(skuInfo.skuSpec);
        // //计量单位
        // $('#inSkuUnit').val(skuInfo.unitId);

        $("#productTypeId2").val(skuInfo.productTypeId);

        // //基础单位数量
        // $('#inUnitCount').val(skuInfo.baseUnitCount);

        //产品性质
        $("#productNature").val(skuInfo.assemblyNature);

        admin.reqSync(
          "enterprise/product/admin/productUnit/getIsBaseUnitProductUnitByType",
          {
            type: 0,
            productTypeId: skuInfo.productTypeId
          },
          (res) => {
            if (res.code === 200) {
              if (res.data != null) {
                let infoName = res.data.name || "";
                let infoId = res.data.id || "";
                $("#inUnit").val(infoName);
                $("#inUnitId").val(infoId);
              } else {
                $("#inUnit").val("");
                $("#inUnitId").val("");
              }
            }
          },
          "get"
        );
        //说明
        $("#inRemark").val(skuInfo.remark);

        $("#mainCalWay").val(skuInfo.mainCalWay);

        $("#mainUnitRate").val(skuInfo.mainUnitRate);
        $("#subCalWay").val(skuInfo.subCalWay);

        $("#subUnitRate").val(skuInfo.subUnitRate);
        $("#costCheckType").val(skuInfo.costCheckType);
        $("#checkStatus").val(skuInfo.checkStatus);
        $("#boxStatus").val(skuInfo.boxStatus);
        $("#minPrice").val(skuInfo.minPrice);
        $("#suggestionMinPrice").val(skuInfo.suggestionMinPrice);

        //主计量方式的改变事件
        admin.req("enterprise/product/admin/productType/getProductTypeVoById", { productTypeId: skuInfo.productTypeId }, (res) => {
          if (res.code === 200) {
            //包装单位集合
            productUnitList = res.data.productUnitList;
            productUnitList.forEach((v) => {
              if (v.calWay == skuInfo.subCalWay) {
                $("#subUnitId").append(new Option(v.name, v.id)); // 下拉菜单里添加元素
              }
            });

            productUnitList.forEach((v) => {
              if (v.calWay == skuInfo.mainCalWay) {
                $("#mainUnitId").append(new Option(v.name, v.id)); // 下拉菜单里添加元素
              }
            });
            form.render("select");
            $("#mainUnitId").val(skuInfo.mainUnitId);
            $("#subUnitId").val(skuInfo.subUnitId);
          }
        });

        xmSelect.get("#productTypeName")[0].update({ disabled: true });
        form.render("select");
      }
    });

    form.on("select(mainCalWay)", function (data) {
      $("#mainUnitId").empty();
      if (data.value) {
        productUnitList.forEach((v) => {
          if (v.calWay == data.value) {
            $("#mainUnitId").append(new Option(v.name, v.id)); // 下拉菜单里添加元素
          }
        });
      }
      form.render("select");
    });

    form.on("select(subCalWay)", function (data) {
      $("#subUnitId").empty();
      if (data.value) {
        productUnitList.forEach((v) => {
          if (v.calWay == data.value) {
            $("#subUnitId").append(new Option(v.name, v.id)); // 下拉菜单里添加元素
          }
        });
      }
      form.render("select");
    });

    //物料类型
    admin.initDataSelectTree(
      true,
      "enterprise/product/admin/productType/getAllTreeData",
      { materialNatureList: [2, 3, 7] },
      "productTypeName",
      null,
      "物料分类",
      "productTypeId",
      function (data) {
        let productTypeId = data.change[0].value;
        //主计量方式的改变事件
        admin.req("enterprise/product/admin/productType/getProductTypeVoById", { productTypeId: productTypeId }, (res) => {
          if (res.code === 200) {
            //包装单位集合
            productUnitList = res.data.productUnitList;
          }
        });

        //基础单位
        admin.reqSync(
          "enterprise/product/admin/productUnit/getIsBaseUnitProductUnitByType",
          {
            type: 0,
            productTypeId: productTypeId
          },
          (res) => {
            if (res.data != null) {
              let infoName = res.data.name || "";
              let infoId = res.data.id || "";
              $("#inUnit").val(infoName);
              $("#inUnitId").val(infoId);
            } else {
              $("#inUnit").val("");
              $("#inUnitId").val("");
            }
          },
          "get"
        );
      }
    );

    //产品性质
    admin.getDictList("productNature", "product_assembly_nature", null, "产品性质");

    // //计量单位
    // admin.getDictList("inSkuUnit", "sys_product_detail_calculate_unit", null, "计量单位");

    // Sku老数据信息
    admin.initDataSelectAndMap(
      "enterprise/product/admin/productDetailWMS/list",
      { categoryType: "production", limit: 9999 },
      "inSkuCodeHave",
      null,
      "SKU物料",
      "skuCode",
      null,
      oldSkuInfo
    );

    //重新渲染基础单位
    // admin.reqSync('enterprise/product/admin/productUnit/getIsBaseUnitProductUnitByType', {
    //     type: 0,
    //     productTypeId: data.productTypeId
    // }, res => {
    //     if (res.code === 200) {
    //         if (res.data != null) {
    //             let infoName = res.data.name || '';
    //             let infoId = res.data.id || '';
    //             $('#inUnit').val(infoName);
    //             $('#inUnitId').val(infoId);
    //         }else{
    //             $('#inUnit').val("");
    //             $('#inUnitId').val("");
    //         }
    //     }
    // }, 'get');

    /**
     * 初始化评审详情
     */
    admin.req("enterprise/product/admin/productReview/detail/" + data.id, {}, function (res) {
      if (res.code == 200) {
        form.val("productAuditReviewForm", res.data === undefined ? null : res.data);
        //初始化文件
        $("#addHeaderPdf").html(
          '<div class="attachments">' +
            '<div><img name="attachments" src="../../../admin/assets/images/attachmentsIcon/pdf.png"><span class="file-a">' +
            name +
            "</span></div></div>"
        );
        $("#attachmentPdf").val(res.data.attachmentPdfUrl);
        imagUrl = res.data.attachmentPdfUrl;
        $("#fileName").text(res.data.fileName);
        $(".attachments").click(function () {
          let json = {};
          json.attachment = imagUrl;
          showViewAttachmentModel(json);
        });
        imagUrl = res.data.attachmentPdfUrl;
        //PDF预览
        if (imagUrl && imagUrl.indexOf(".pdf") !== -1) {
          PDFObject.embed(imagUrl, "#TuZhiPdf");
        } else {
          let attachmentHtml = "";
          imagUrl.split(",").forEach((attachmentUrl, index) => {
            attachmentHtml += '<div><div><img style="width: 640px;height: 345px;" src="' + attachmentUrl + '"></div></div>';
          });
          $("#TuZhiPdf").html(attachmentHtml);
        }
        form.render(); //菜单渲染 把内容加载进去
      } else {
        layer.msg(res.msg, { icon: 2 });
      }
    });

    $(".attachments").click(function () {
      let json = {};
      json.attachment = imagUrl;
      showViewAttachmentModel(json);
    });

    form.on("submit(productAuditFormSubmit)", function (d) {
      layer.load(2);
      let params = d.field;
      params.id = data.id;
      params.reviewCatalogId = data.reviewCatalogId;
      params.customerId = data.customerId;
      params.inSkuCode=params.inSkuCode
      admin.req(
        "enterprise/product/admin/productReview/link",
        params,
        function (res) {
          layer.closeAll("loading");
          if (res.code == 200) {
            layer.msg(res.msg, { icon: 1 });
            table.reload("reviewTableInfo");
            layer.closeAll("page");
          } else {
            layer.msg(res.msg, { icon: 2 });
          }
        },
        "POST"
      );
      return false;
    });

    // 查看附件
    function showViewAttachmentModel(data) {
      admin.open({
        type: 1,
        area: ["60%", "80%"],
        offset: "65px",
        title: "查看附件",
        content: $("#viewAttachmentHtml").html(),
        success: function () {
          if (data.attachment && data.attachment.indexOf(".pdf") !== -1) {
            PDFObject.embed(data.attachment, "#example1");
          } else {
            var attachmentHtml = "";
            data.attachment.split(",").forEach((attachmentUrl, index) => {
              attachmentHtml += '<div><div><img src="' + attachmentUrl + '"></div></div>';
            });
            $("#example1").html(attachmentHtml);
          }
        }
      });
    }
  });
</script>
